import { defineComponent, ref, h } from 'vue'
import {
  NLayout,
  NLayoutContent,
  NLayoutHeader,
  useMessage,
  useDialog
} from 'naive-ui'

import HeaderBar from './components/headerbar'
import SiderBar from './components/siderbar'
import TabsBar from './components/tabsbar'
import { useI18n } from 'vue-i18n'
import { useStore } from 'vuex'
import { useUserStore } from '@/store/user/user'
import { useRouter } from 'vue-router'

const Content = defineComponent({
  name: 'TDContent',
  setup() {
    window.$message = useMessage()
    window.$dialog = useDialog()
    window.$store = useStore()
    window.$t = useI18n().t
    window.$router = useRouter()
    //第一次进入初始化用户信息并打开首页标签
    window.$store.commit('updateUserInfo', useUserStore().getUserInfo)
    window.$store.commit('clearTabPanes')
    return {}
  },
  mounted() {
    //禁止浏览器刷新
    // window.onbeforeunload = function (e) {
    //   return false
    // }
  },
  render() {
    return (
      <NLayout style='height: 100%' has-sider>
        <SiderBar />
        <NLayout style='position :relation'>
          <NLayoutHeader style='height: 45px'>
            <HeaderBar />
          </NLayoutHeader>
          <NLayoutContent
            content-style='margin: 3px'
            style='position:absolute;top:45px;left:0;bottom:0;width:100%'
          >
            <TabsBar />
          </NLayoutContent>
        </NLayout>
      </NLayout>
    )
  }
})
export default Content
